perl scripts stdin/pipe reading problem [closed]

Posted by user4541 on Stackapps See other posts from Stackapps or by user4541
Published on 2010-12-27T06:57:14Z Indexed on 2010/12/27 7:58 UTC
Read the original article Hit count: 502

Filed under:
|

I have 2 scripts for a task.

The 1st outputs lines of data (terminated with RT/LF) to STDOUT now and then.

The 2nd keeps reading data from STDIN for further processing in the following way:

use strict; my $dataline; while(1) { $dtaline = ""; $dataline = ; until( $dataline ne "") { sleep(1); $dataline = ; }

#further processing with a non-empty data line follows
#

} print "quitting...\n";

I redirect the output from the 1st to the 2nd using pipe as following: perl scrt1 |perl scpt2.

But the problem I'm having with these 2 scpts is that it looks like that the 2nd scpt keeps getting the initial load of lines of data from the 1st scpt if there's no data anymore.

Wonder if anybody having similar issues can kindly help a bit?

Thanks.

© Stackapps or respective owner

Related posts about discussion

Related posts about perl